/**
  * PicDownloader 0.0.2a
  * PicDownloader is a small program for downloading images from imageboards.
  * This program was created using Qt 4.7.0
  * Version for desktop. See more on http://code.google.com/p/pic-downloader/
  *
  * Copyright (c) 2012, nd.anonymous.kun All rights reserved.
  *
  * Please contact with me by E-mail/XMPP: nd.anonymous.kun@gmail.com
  **/

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include "include/version.h"
#include "include/boards.h"
#include "include/img_url.h"

#include <QMainWindow>
#include <QDesktopServices>
#include <QDir>
#include <QFileDialog>
#include <QImage>
#include <QtNetwork/QNetworkAccessManager>
#include <QtNetwork/QNetworkReply>
#include <QtNetwork/QNetworkRequest>
#include <QString>
#include <QStringList>
#include <QUrl>


namespace Ui {
    class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT


public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();


private:
    Ui::MainWindow *ui;

    QUrl url;
    QString path;
    QStringList boardsAddress;
    QStringList imgList;

    int board;
    int currentImage;

    int minFSize;
    int maxFSize;
    int minImSizeW, minImSizeH;
    int maxImSizeW, maxImSizeH;


private slots:
    bool eventFilter(QObject *obj, QEvent *event);

    void setVersions();
    void initBoards();
    void initPath();

    void showMessage(const char*);

    bool testURL();
    bool readParametrs();
    bool createDirectory();
    bool startDownloading();
    void QnamFinished(QNetworkReply*);
    bool parseHtml (QNetworkReply* reply);
    bool downloadImages();
    void getNextImage();
    void getImageFinished(QNetworkReply*);

    void on_lineEdit_thread_returnPressed();
    void on_lineEdit_thread_textChanged(QString );

    void on_checkBox_maxImSize_stateChanged(int );
    void on_checkBox_minImSize_stateChanged(int );
    void on_checkBox_maxFSize_stateChanged(int );
    void on_checkBox_minFSize_stateChanged(int );

    void on_toolButton_test_clicked();
    void on_pathSelectButton_clicked();
    void on_launchButton_clicked();
};

#endif // MAINWINDOW_H
